package androidx.test.runner.permission;

/* loaded from: classes.dex */
public abstract class ShellCommand {
    private static final String SAFE_PUNCTUATION = "@%-_+:,./";

    /* JADX INFO: Access modifiers changed from: package-private */
    public abstract void execute() throws Exception;

    /* JADX INFO: Access modifiers changed from: package-private */
    public static String shellEscape(String word) {
        int length = word.length();
        if (length == 0) {
            return "''";
        }
        for (int i = 0; i < length; i++) {
            char charAt = word.charAt(i);
            if (!Character.isLetterOrDigit(charAt) && SAFE_PUNCTUATION.indexOf(charAt) == -1) {
                String replace = word.replace("'", "'\\''");
                StringBuilder sb = new StringBuilder(String.valueOf(replace).length() + 2);
                sb.append("'");
                sb.append(replace);
                sb.append("'");
                return sb.toString();
            }
        }
        return word;
    }
}
